package com.supermap.originTest;


import com.supermap.data.Layouts;
import com.supermap.data.Workspace;
import com.supermap.data.WorkspaceConnectionInfo;
import com.supermap.data.WorkspaceType;
import com.supermap.layout.LayoutElements;
import com.supermap.layout.MapLayout;
import com.supermap.mapping.Map;
import com.supermap.ui.MapLayoutControl;


public class TestChangeLayoutBounds {

    /**
     * 程序入口点
     * The entrance of the programme.
     */
    public static void main(String[] args) {


//        

        Workspace workspace = new Workspace();
        MapLayoutControl mapLayoutControl = new MapLayoutControl();
        WorkspaceConnectionInfo conInfo = new WorkspaceConnectionInfo(
                "E:\\MapData\\202407\\chongqing\\WorkSpace.smwu");
        conInfo.setType(WorkspaceType.SMWU);
        workspace.open(conInfo);

        //打开布局模板
        mapLayoutControl.getMapLayout().setWorkspace(workspace);
        Layouts layouts = workspace.getLayouts();
        String layoutName = layouts.get(0);
        System.out.println(layoutName);
        MapLayout mapLayout = mapLayoutControl.getMapLayout();
        mapLayout.setWorkspace(workspace);
        mapLayout.open(layoutName);


        //获取布局的对应地图
        LayoutElements elements = mapLayout.getElements();
        int id = elements.getID();

        mapLayoutControl.setActiveGeoMapID(id);
        Map map = mapLayoutControl.getActiveMap();
        System.out.println(map.getName());
        map.setViewBoundsLocked(false);
        System.out.println(map.getScale());
        map.setCustomBoundsEnabled(true);
        map.setCustomBounds(map.getBounds());

        map.setScale(3E-7);
        map.setCenter(map.getBounds().getCenter());
        map.setViewBoundsLocked(true);

        System.out.println(map.getScale());



        workspace.save();
        mapLayout.outputLayoutToJPG("E:\\MapData\\202410\\test.jpg", 300, 100);
        workspace.dispose();





    }



}  

